#include<iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x; cin >> x;
        int flag = true;
        for (int j = 2; j <= x / j; j++)
        {
            if (x % j == 0) 
            {
                flag = false;
                break;
            }
        }
        if (flag) cout << x  << " ";
        else if (x <= 1) cout << x << " ";
    }
    return 0;
}